package org.sdau.rotten.library.service.Impl;


import org.sdau.rotten.library.entity.Action;
import org.sdau.rotten.library.service.AppointService;
import org.sdau.rotten.library.dao.AppointmentDAO;
import org.sdau.rotten.library.exception.NoNumberException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("appointmentServiceImpl")
public class AppointServiceImpl implements AppointService {
    @Autowired
    private AppointmentDAO appointmentDao;
    @Override
    public List<Action> findAll(String StudentId) {
        System.out.println("查询了%"+StudentId+"%的记录");
        List<Action> result = appointmentDao.studentActions('%'+StudentId+'%');
        System.out.println(result.get(0).getAppointTime());
        return result;
    }

    @Override
    public int delete(String id) {
       int back = appointmentDao.deleteAction(Integer.parseInt(id));
       if(back<=0)
       {
           throw new NoNumberException(221,"删除记录失败");
       }
       else
           return back;
    }
}
